import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    title: 'Flutter教程03-3',
    home: LocalImageDemo(),
  ));
}

class ImageDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('从网络获取图片'),
      ),
      body: Center(
        child: Image.network(
          'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=160305517,2880909992&fm=26&gp=0.jpg',
          // fit: BoxFit.fill,//拉伸全屏
          //   fit: BoxFit.contain,//全图显示,原比例还原,可能会有空隙
          // fit: BoxFit.cover,//显示可能被拉伸,可能裁剪,充满
          fit: BoxFit.fitHeight,
        ),
      ),
    );
  }
}

class LocalImageDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('获取本地图片'),
      ),
      body:
        Image.asset(
          'images/yueliang.png',
          repeat: ImageRepeat.repeatX,
        ),

    );
  }
}
